#include <chrono>
#include "PadLog.h"

long long getNanoTimeStamp()
{
    return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
}

enum EnumTest
{
    Enum_T1 = 9901,
    Enum_T2 = 9902
};
int main()
{
    const char* file_name = "test_log";
    PadLog::init(file_name, "", PadLog::Pl_All);

    auto fun = []()
    {
        const char* test = "She is a pretty girl.";
        bool b = true;
        char _cr = 'w';
        float f1 = 99.99;
        typedef std::string ACCT;
        std::string test11("111111111111111");
        const char* char_null = NULL;
        char test_char_arr[6] = {'1', '2', '3', '4', '5', '\0'};
        char test_char_arr1[6] = {'1', '2', '3', '4', '5', '6'};
        for (int32_t i = 1000; i <= 501000; ++i)
        {
            PadLog::debug("test none params");
            PadLog::error("test log, can not catch param:{ }, index:{} ", i);
            PadLog::debug("test log, int64_t is {}", getNanoTimeStamp());
            PadLog::debug("test log, bool is {}, float is {}, NullStr is {}, Enum1 is {}, Enum2 is {}", b, f1, char_null, Enum_T1, Enum_T2);
            PadLog::warn("test log, CharArray1 is {}, CharArray2 is {}", test_char_arr, test_char_arr1);
            PadLog::debug("test log, index is {}, str is {}, words is {}", std::to_string(i), "test_test_test", test);
            PadLog::debug("test log, test CharArray is {},{}", "22222222222", "test_test_test");
            PadLog::info("test log, test CharArray is {},{}, char:{}, std::string:{}", "1test_test_test1", "2test_test_test2", _cr, std::string("gggggggggg"));
            PadLog::debug("test log, abc is {} efg is {} ggg is {}", i, std::to_string(i), "jjjjj");
			PadLog::all("test log, index: {{{{}}}}}, ptr:{}, {}, {}, {}, {}, empty param:{}, {}", i, &i, std::to_string(i).c_str(), "hhhhh", getNanoTimeStamp(), 123456.789123);
        }
    };
    //多线程测试
#if (0)
    std::thread t1(fun);
    std::thread t2(fun);
    std::thread t3(fun);
    std::thread t4(fun);
    std::thread t5(fun);
    std::thread t6(fun);
#endif
    fun();
#ifdef _WIN32
    while (1)
        Sleep(1);
#else
    while (1)
        usleep(1000);
#endif
    return 0;
}
